package com.example.proxy;

import java.lang.reflect.Proxy;

/**
 * Description:
 * User: 阿宾
 * Date: 2025-05-04
 * Time: 20:57
 */
public class DynamicMain {
    public static void main(String[] args) {
        //动态代理，JDK实现

        RealHouseSubject target = new RealHouseSubject();
        //创建一个代理类：通过被代理类，被代理实现的接口，方法调用处理器来创建。
        HouseSubject proxy = (HouseSubject)Proxy.newProxyInstance(
                HouseSubject.class.getClassLoader(),
                new Class[]{HouseSubject.class},
                new JDKInvocationHandler(target));
        proxy.rentHouse();
    }

}
